package com.sysassist;

import com.sysassist.procmgr.ProcMgrActivity;
import com.sysassist.servicemgr.ServiceMgrActivity;
import com.sysassist.taskmgr.TaskMgrActivity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;
import android.widget.Toast;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

public class MainActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
//        // 取得TabHost对象
        TabHost mTabHost = getTabHost();
        // 取得Resources对象
        Resources res = getResources();

        Intent intent;
        TabSpec tabSpec;
        
        /** 为TabHost添加标签 */
        // process
        intent = new Intent(this, ProcMgrActivity.class);
		tabSpec = mTabHost.newTabSpec("process")
			.setIndicator("进程", res.getDrawable(R.drawable.proces))
			.setContent(intent);
		mTabHost.addTab(tabSpec);
//		// task
        intent = new Intent(this, TaskMgrActivity.class);
		tabSpec = mTabHost.newTabSpec("task")
			.setIndicator("Task", res.getDrawable(R.drawable.task))
			.setContent(intent);
		mTabHost.addTab(tabSpec);
//		// service
        intent = new Intent(this, ServiceMgrActivity.class);
		tabSpec = mTabHost.newTabSpec("service")
			.setIndicator("Service", res.getDrawable(R.drawable.service))
			.setContent(intent);
		mTabHost.addTab(tabSpec);
		
		// 设置TabHost的背景颜色
//		mTabHost.setBackgroundColor(Color.argb(150,22,70,150));
		// 设置TabHost的背景图片资源
//		mTabHost.setBackgroundResource(R.drawable.icon);
		// 设置当前显示哪个标签
		mTabHost.setCurrentTab(0);
		
		// 标签切换事件处理，setOnTabChangedListener
		mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
			@Override
			public void onTabChanged(String tabId) {
				Toast toast = Toast.makeText(getApplicationContext(),
						"This is " + tabId + ".", Toast.LENGTH_SHORT);
				toast.show();
			}
		});
    }
    
//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//    	MenuInflater inflater = this.getMenuInflater();
//    	inflater.inflate(R.layout.menu, menu);
//    	return true;
//    }
//    
//    @Override
//    public boolean onOptionsItemSelected(MenuItem mi) {
//    	int id = mi.getItemId();
//    	if (id == R.id.exit) {
//    		this.finish();
//    	} else {
//    		
//    	}
//    	return true;
//    }
}